package club.haomoon.core.validator;

import club.haomoon.core.validator.annotation.IntArrayEmpty;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;


/**
 * -------------------------
 * @Description: 验证整数数组是否为空
 * @Author: Wangjianwei
 * @Date: 2025/02/12 16:38
 * -------------------------
 */
public class IntArrayEmptyValidator implements ConstraintValidator<IntArrayEmpty, int[]> {

    @Override
    public void initialize(IntArrayEmpty constraintAnnotation) {
        ConstraintValidator.super.initialize(constraintAnnotation);
    }

    @Override
    public boolean isValid(int[] value, ConstraintValidatorContext context) {
        if (value == null) {
            return false;
        }

        return value.length > 0;
    }

}
